import 'package:flutter_admin/pages/common/cry/cry_all.dart';
import 'package:flutter_admin/pages/common/cry/vo/select_option_vo.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_admin/pages/common/cry/cry_button.dart';
import 'package:flutter_admin/api/odoo/dynamic_data_api.dart';
import 'package:flutter_admin/models/odoo/product_template.dart';
import '../../../../generated/l10n.dart';

class ProductTemplatePrintDialog extends StatefulWidget {
  ProductTemplatePrintDialog();

  @override
  _ProductTemplatePrintDialogState createState() => _ProductTemplatePrintDialogState();
}

class _ProductTemplatePrintDialogState extends State<ProductTemplatePrintDialog> {

  // late List<Widget> children;
  final GlobalKey<FormState> formKey = GlobalKey<FormState>();

  ProductTemplate  productTemplate = ProductTemplate();


  @override
  void initState() {
    super.initState();
    _loadData();
  }

  _loadData() async{
    setState(() { });
  }
  @override
  Widget build(BuildContext context) {
    var form = Form(
      key: formKey,
      child: Wrap(
        children: <Widget>[
          CryInput(
            label: '产品名称',
            value: productTemplate.name,
            onSaved: (v) {
              productTemplate.name = v;
            },
          ),
          CryInput(
            label: '产品编码',
            value: productTemplate.defaultCode,
            onSaved: (v) {
              productTemplate.defaultCode = v;
            },
          ),

        ],
      ),
    );
    var buttonBar = ButtonBar(
      alignment: MainAxisAlignment.center,
      children: <Widget>[
        CryButton(
          label: "确定",
          onPressed: () {
            FormState form = formKey.currentState!;
            form.save();
            Navigator.pop(context, productTemplate);
          },
          iconData: Icons.save,
        ),
        CryButton(
          label: S.of(context).cancel,
          onPressed: () {
            Navigator.pop(context);
          },
          iconData: Icons.cancel,
        )
      ],
    );
    var result = Scaffold(
      appBar: AppBar(
        title: Text("查询"),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [form],
        ),
      ),
      bottomNavigationBar: buttonBar,
    );
    return SizedBox(
      width: 650,
      height: 650,
      child: result,
    );
    // return result;
  }
}